package com.yiban.demo.LoginUser.DAO;

import com.yiban.demo.LoginUser.Entity.LoginUserPO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;



@Repository
@Mapper
//命名规范xxMapper
//方法名要表现对数据库做什么操作
public interface LoginUserMapper {
    @Insert("insert into login_user (username, password, nickname,phone_number) VALUE (#{username},#{password},#{nickname},#{phoneNumber})")
    boolean insertOne(LoginUserPO loginUserPO);

    @Select("select * from login_user where username = #{username} limit 1")
    LoginUserPO selectOneByUsername(String username);

    @Update("update login_user set password = #{newPassword} where user_id = #{id}")
    boolean updatePasswordById(int id,String newPassword);

    @Update("update login_user set password = #{newNickname}")
    boolean updateNicknameById(int id,String newNickname);

    @Update("update login_user set is_used = #{isUsed}")
    boolean updateIsUsedByUsername(String username,boolean isUsed);
}
